<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:mochi="http://www.mochikit.com/">
  <xi:include href="master.html" />

<head>

<title>ResourcePools and VMs</title>

<link rel="stylesheet" type="text/css" media="screen" href="${tg.url('/css/style.css')}" />

<script type = "text/javascript">

var temp_sort_key = 1; //specify the column to sort when loading the page
var numtables = 2; //number of tables in the web page
var sort_managers_array = new Array(numtables);

</script>

<script type = "text/javascript" src="/cloudcrvjs/sortable_tables.js"></script>
<script type = "text/javascript" src="/cloudcrvjs/general_format.js"></script>
<script type = "text/javascript" src="/cloudcrvjs/ibox.js"></script>
<!--ibox must go after sortable_tables-->
<script type = "text/javascript">

/* <![CDATA[ */
function giveMeElementByID(elid) {

  var elem;

  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( elid );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[elid];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[elid];

  return elem;
  
}

function toggleLayer( whichLayer, method )
{
  var elem, vis;

  elem=giveMeElementByID(whichLayer);

  vis = elem.style;

  if(method=="on") 
    vis.display='block';
  else if(method=="off")
    vis.display='none';
  else {
    if(!(vis.display!='' || elem.offsetWidth==undefined || elem.offsetHeight == undefined)) {
      vis.display = ((elem.offsetWidth==0 || elem.offsetHeight==0))?'block':'none';
    } else {
      vis.display = (vis.display=='' || vis.display=='block')?'none':'block';
    }
  }
}

function extraload()
{
    //use for anything that needs to be done on load
    //for specifying a different sort_key for a specific table
    //sort_managers_array[1].sortkey = 0;
}

function extraunload()
{
    //use for anything that needs to be done on unload
}

addLoadEvent (function () { pageload("physical", 2); extraload(); });
/* ]]> */
</script>

</head>

<!--see roles2.html for documentation about how tables are made-->

<body onUnload = "unload('physical', 2); extraunload(); "> <!--the second argument of unload must be equal to numtables (see above)-->

<!-- table for the RPs -->
<div>

 <p>List of Resource Pools and VMs</p>

 <div py:for="i in range(0, len(rps))">
  <p><font size="+2" color="blue">Resource Pool</font><font size="+3" color="red"><bold>&nbsp;&nbsp;#${rps[i].RP_ID}</bold></font><font size="+2" color="blue">:&nbsp;<bold>${rps[i].getAttr("name")}</bold></font></p>
  <p><font color="blue"><i>${rps[i].getAttr("doc")}</i></font></p>
  <p><a href="javascript:void(0)" onclick="javascript:toggleLayer('divmakers_${rps[i].RP_ID}','switch');"><h4>&#9656; Show Details</h4></a></p>
  <div id="divmakers_${rps[i].RP_ID}" style="display: None; margin: 10px 20px 10px 20px;">
   <table>
    <tr>
     <th>VM Maker</th>
     <td><font color="blue">${rps[i].getMaker("vm").getAttr("name")}</font>, ${rps[i].getMaker("vm").getAttr("doc")}</td>
    </tr>
    <tr>
     <th>Profile Maker</th>
     <td><font color="blue">${rps[i].getMaker("profile").getAttr("name")}</font>, ${rps[i].getMaker("profile").getAttr("doc")}</td>
    </tr>
    <tr>
     <th>Client Maker</th>
     <td><font color="blue">${rps[i].getMaker("client").getAttr("name")}</font>, ${rps[i].getMaker("client").getAttr("doc")}</td>
    </tr>
   </table>
  </div>

  <p><font size="+1" color="blue"><bold>List of VMs</bold></font></p>

  <div id = "table${i}" style="overflow:auto; width:800px;">

  <table border = "1" id="sortable_table${i}" class="datagrid sofT" cellspacing="0">
    <thead>
      <tr>
          <th class="helpHed" mochi:format="int" style="cursor:pointer">VM_ID</th>
          <th class="helpHed" mochi:format="str" style="cursor:pointer">Name</th>
	  <th class="helpHed" mochi:format="str" style="cursor:pointer">Current Status</th>
	  <th class="helpHed" mochi:format="str" style="cursor:pointer">Target Status</th>
	  <th class="helpHed" mochi:format="str" style="cursor:pointer">Identifier</th>
	  <th class="helpHed" mochi:format="str" style="cursor:pointer">PublicIP</th>
	  <th class="helpHed" mochi:format="str" style="cursor:pointer">PrivateIP</th>
	  <th class="helpHed" mochi:format="str" style="cursor:pointer">Attributes</th>
	  <th class="helpHed" mochi:format="str" style="cursor:pointer">Roles</th>
      </tr>
    </thead> 
    <tbody>
      <div py:for="ivm in rps[i].vm">
        <tr>
	    <td >
	      ${ivm.VM_ID}</td>
	    <td >
	      ${ivm.getAttr("name")}</td>
	    <td  bgcolor="${SC_colors[ivm.currentSC % len(SC_colors)]}">
	      <font color = "black">
	      ${SC_table[ivm.currentSC]}</font></td>
	    <td  bgcolor="${SC_colors[ivm.targetSC % len(SC_colors)]}">
	      <font color = "black">
	      ${SC_table[ivm.targetSC]}</font></td>
	    <td >
	      ${ivm.getAttr("identifier")}</td>
	    <td >
	      ${ivm.getAttr("PublicIPV4")}</td>
	    <td >
	      ${ivm.getAttr("PrivateIPV4")}</td>

	    <td >     
	      <a href = "${'/dispvm/'+ivm.getAttr('name')+'/attr'}" rel = "ibox">Show</a></td>
	    <td >
	      <a href = "${'/dispvm/'+ivm.getAttr('name')+'/roles'}" rel = "ibox">Show</a></td>
	</tr>
      </div>
    </tbody>
  </table>
  </div>
 </div>
</div>

</body>

</html>
